//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_TEXTURE_H
#define _UX_TEXTURE_H

#include "CTexture.h"

namespace Engine
{
namespace Resources
{

	//
	// Texture 2D
	//

	class _EXPORT_ CTexture2D : public CTexture
	{
		friend class CBitmapFont;
		friend class CSprite;
		
	protected:
		CTexture2D(const char *pFileName, e_tex_flags::type eFlags);
		virtual ~CTexture2D();

		virtual bool _Load(IFilePtr pFile, uint uSize);
		virtual bool _Save(IFilePtr pFile);

	public:
		bool	Copy(TImage2D &sImage, e_tex_format::type eFormat = e_tex_format::UNKNOWN, bool bMipMaps = true);
		bool	Create(const TImage2D &sImage, e_tex_flags::type eFlags = e_tex_flags::UNKNOWN);
		bool	Create(const uvec2 &vDim, e_tex_format::type eFormat, e_tex_swizzle::type eSwizzle = e_tex_swizzle::AUTO, e_tex_flags::type eFlags = e_tex_flags::UNKNOWN);
		bool	CopyToBuffer(GLuint uBufIdx, e_tex_format::type eFormat = e_tex_format::UNKNOWN, uint uOffset = 0);		// for render to vbo
		bool	AddImage(const TImage2D &sImage, const uvec2 &vOffset = uvec2());
		
		virtual bool	Create(const uvec3 &vDim, e_tex_format::type eFormat, e_tex_swizzle::type eSwizzle,
								e_tex_flags::type eFlags, uint16 uSamples = 0);

		virtual e_resource::type	GetType()	const	{ return e_resource::TEXTURE_2D; }

		static CTexture2DPtr s_CreateTexture2D(const char *pFileName, e_tex_flags::type eFlags);
	};

//-------------------------------------------------------------------

}	// EngineResource
}	// Engine

#endif	// _UX_TEXTURE_H